#ifndef _OLD_ERROR_HANDLER_H
#define _OLD_ERROR_HANDLER_H

#include "_old_ErrorEvent.h"
#ifdef _WIN32
	#include <conio.h>
#else
	#include "../common/conio.h"
#endif
#include <string>
#include <GLFW/glfw3.h>

using std::string;

typedef char ErrorFlags;

namespace mp_error
{
	/*!----------------------------------------------------------------
	*	@class		ErrorHandler
	*	@brief		Writes errors to the applications console as well
	*				as the option of writing it to file and linking
	*				event listeners to receive each error.
	*
	*	@author		Mitchell Pell
	*	@date		9/28/2013
	*	@version	1.0
	*
	----------------------------------------------------------------*/
	class ErrorHandler
	{
	public:
		/*!------------------------------------------------------------
		*	@enum		ErrorWriteFlags
		*	@brief		
		*
		-------------------------------------------------------------*/
		enum ErrorWriteFlag
		{
			ERW_NONE	= 0x00,
			ERW_CONSOLE = 0x01,
			ERW_FILE	= 0x02,
			ERW_EVENT	= 0x04
		};

		ErrorHandler();
		~ErrorHandler();

		void WriteError(const char* msg);
		void WriteError(const string msg);


		void AddErrorEventListener(ErrorEvent* listener);


		void ResetWriteFlags()
			{m_errorWriteFlags = static_cast<ErrorFlags>(ERW_CONSOLE);}
		void AddWriteFlag(ErrorWriteFlag flag)
			{m_errorWriteFlags != static_cast<ErrorFlags>(flag);}
		void RemoveWriteFlag(ErrorWriteFlag flag)
			{m_errorWriteFlags &= ~static_cast<ErrorFlags>(flag);}

	private:
		void WriteErrorToFile(const string msg);
		void SendErrorEvents(const string msg);
		void WriteErrorToConsole(const char* msg);

		ErrorFlags			m_errorWriteFlags;
		ErrorEvent**		m_errorListeners;
		int					m_errorListenerCount;
	};
}
#endif